package com.log.demo.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author weijinhao
 * @date 2023/11/18 16:59
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ResultMsg {
    private int errorCode;

    private String errorMsg;

    private Object bizContent;

    public ResultMsg(ErrorCode errorCode, Object bizContent) {
        this.errorCode = errorCode.getCode();
        this.errorMsg = errorCode.getMsg();
        this.bizContent = bizContent;
    }

    public static ResultMsg success(Object bizContent) {
        return new ResultMsg(ErrorCode.success,bizContent);
    }

    public static ResultMsg fail(Object bizContent) {
        return new ResultMsg(ErrorCode.fail,bizContent);
    }

    public static ResultMsg other(ErrorCode errorCode,Object bizContent) {
        return new ResultMsg(errorCode,bizContent);
    }
}
